package database;

public class MixCM {
	Integer id;
	String mname;
	String cname;
	public static String sqls(String id,String mname,String cname) {
		String sql = "select c.id,c.name as cname,m.name as mname from college c,major m where m.c_id=c.id";		
		if(id==null||mname==null||cname==null) return sql+" order by c.id";
		if(id.isEmpty()&&mname.isEmpty()&&cname.isEmpty()) return sql+" order by c.id";
		if(!id.isEmpty()) sql += ",id="+Integer.parseInt(id);
		if(!mname.isEmpty()) sql +=",mname='"+mname+"'";
		if(!cname.isEmpty()) sql +=",cname='"+cname+"'";
		return sql+" order by c.id";
	}
	public static String sqls(String mname,String cname) {
		String sql = "select c.id,c.name as cname,m.name as mname from college c,major m where m.c_id=c.id";		
		if(mname==null||cname==null) return sql+" order by c.id";
		if(mname.isEmpty()&&cname.isEmpty()) return sql+" order by c.id";
		if(!mname.isEmpty()) sql +=" and m.id='"+mname+"'";
		if(!cname.isEmpty()) sql +=" and c.id='"+cname+"'";
		return sql+" order by c.id";
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getMname() {
		return mname;
	}
	public void setMname(String mname) {
		this.mname = mname;
	}
	public String getCname() {
		return cname;
	}
	public void setCname(String cname) {
		this.cname = cname;
	}
}
